﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Collections.ObjectModel;

namespace Medianamik.UI.ImportExportManagement
{
    public class Record
    {
        public Record(RecordType recordType, String cultureName)
        {
            if (recordType == null)
                throw new ArgumentNullException("recordType");

            if (String.IsNullOrEmpty(cultureName))
                throw new ArgumentException("cultureName");

            _recordType = recordType;
            _cultureName = cultureName;
        }

        public Record(RecordType recordType, String cultureName,
            IEnumerable<RecordProperty> properties)
            : this(recordType, cultureName)
        {
            if (properties == null)
                throw new ArgumentNullException("properties");

            if (properties.Count() < 1)
                throw new ArgumentException("Record types must have at lest one property.");

            foreach (RecordProperty property in properties)
            {
                Properties.Add(property);
            }
        }

        public Guid? Id { get; set; }

        public RecordPropertyCollection Properties { get { return _properties; } }
        RecordPropertyCollection _properties = new RecordPropertyCollection();

        public RecordType RecordType
        {
            get { return _recordType; }
        }
        RecordType _recordType;

        public String CultureName
        {
            get { return _cultureName; }
            set
            {
                if (String.IsNullOrEmpty(value))
                    throw new ArgumentException("CultureName");

                _cultureName = value;
            }
        }
        string _cultureName;
    }
}
